package com.weishuang.monitor.leader.commons.entity;

import com.github.pagehelper.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageVO<T> implements Serializable {

    private static final long serialVersionUID = -8536783598154694406L;

    private int current;
    private int size;
    private long total;
    private int pages;

    private List<T> records;


    public static <T> PageVO of(Page<T> data) {
        PageVO<T> pageVO = new PageVO<>();
        pageVO.setCurrent(data.getPageNum());
        pageVO.setSize(data.getPageSize());
        pageVO.setTotal(data.getTotal());
        pageVO.setPages(data.getPages());
        pageVO.setRecords(data.getResult());
        return pageVO;
    }
}
